package com.mocai.merchant.core.mapper;

import com.mocai.merchant.core.domain.Treeable;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/**
 * 可排序的Mapper
 */
@Repository
public interface TreeableMapper {
    <T extends Treeable> void exchange(@Param("source") T source, @Param("target") T target, @Param("table") String table, @Param("idColumn") String idColumn, @Param("sortColumn") String sortColumn);

    <T extends Treeable> void move(@Param("from") T from, @Param("to") T to, @Param("table") String table, @Param("idColumn") String idColumn, @Param("sortColumn") String sortColumn, @Param("parentColumn") String parentColumn);

    <T extends Treeable> Object selectPrevious(@Param("model") T model, @Param("table") String table, @Param("idColumn") String idColumn, @Param("sortColumn") String sortColumn, @Param("parentColumn") String parentColumn);

    <T extends Treeable> Object selectNext(@Param("model") T model, @Param("table") String table, @Param("idColumn") String idColumn, @Param("sortColumn") String sortColumn, @Param("parentColumn") String parentColumn);

    <T extends Treeable> Object selectFirst(@Param("model") T model, @Param("table") String table, @Param("idColumn") String idColumn, @Param("sortColumn") String sortColumn, @Param("parentColumn") String parentColumn);

    <T extends Treeable> Object selectLast(@Param("model") T model, @Param("table") String table, @Param("idColumn") String idColumn, @Param("sortColumn") String sortColumn, @Param("parentColumn") String parentColumn);

    <T extends Treeable> void updateChildrenPath(@Param("model") T model, @Param("oldPath") String oldPath, @Param("table") String table, @Param("pathColumn") String pathColumn, @Param("parentColumn") String parentColumn);

    <T extends Treeable> void update(@Param("model") T model, @Param("table") String table, @Param("idColumn") String idColumn, @Param("sortColumn") String sortColumn, @Param("pathColumn") String pathColumn, @Param("parentColumn") String parentColumn);
}